package com.hqyj.service.impl;
import com.hqyj.dao.GoodsDao;
import com.hqyj.pojo.Goods;
import com.hqyj.service.GoodsService1;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author tanghao
 * @version 1.0
 * @date 2021/8/12 14:25
 */
@Service
public class GoodsServiceImpl1 implements GoodsService1 {
    @Autowired
    private GoodsDao goodsDao;
    @Override
    public int insertGoods(Goods goods) {
        Goods good = new Goods();
        good.setGoodsName(goods.getGoodsName());
        good.setGoodsPic(goods.getGoodsPic());
        good.setGoodsDesc(goods.getGoodsDesc());
        good.setAttributeList(goods.getAttributeList());
        good.setGoodsStatus(goods.getGoodsStatus());
        good.setTypeId(goods.getTypeId());
        good.setGoodPrice(goods.getGoodPrice());
        good.setGoodsStock(goods.getGoodsStock());
        good.setDiscount(goods.getDiscount());
        good.setDeleted(goods.getDeleted());
        good.setCreateTime(goods.getCreateTime());
        good.setUpdateTime(goods.getUpdateTime());
        int i = goodsDao.insertOne(good);
        return i;
    }
    @Override
    public int deleteGoods(Long goodsId) {
        long Id=1;
        Goods goods = goodsDao.getByIdGoodsId(Id);
        System.out.println(goods);
        if(goods.getDeleted()==false){
            goods.setDeleted(true);
        }
        int i = goodsDao.deleteOne(goods.getDeleted(),goodsId);
        System.out.println("删除成功"+i);
        return i;
    }
}
